function [spec,varlr]=varspecar(y,p);
% Estimate the spectrum of Y at frequency zero 
% using an AR of order P 
%
% =============================================
xmat=lagmat(y,p); 
[bet,res,sig]=ols(xmat(p+1:end,1),[xmat(p+1:end,2:end) ones(size(xmat,1)-p,1)]); 
A=sum(conv([1;-bet(1:end-1)'],[1;-bet(1:end-1)'])); 
varlr=var(res)/A; spec=varlr/(2*pi);
varlr=varlr/length(y); 
